package ControlLayer;

import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import DBLayer.DBDiscount;
import ModelLayer.Discount;

public class CtrDiscount {

	DBDiscount dbDisc;
	Discount disc;
	
	public CtrDiscount(){
		dbDisc = new DBDiscount();
		disc = new Discount();
	}
	
	public ArrayList<Discount> getAll() {
		return dbDisc.getAll();
	}

	public Discount find(String type) {
	return dbDisc.find(type);
	}

	public Discount find_byCustomerId(int Cid) {
		return dbDisc.find_byCustomerId(Cid);
	}
	
	public int delete(int sid) {
		return dbDisc.delete(sid);
		}

	public int insert(String type, double minAmount, double discount) {

		Discount disc = new Discount(type,minAmount,discount);
		int rc = -1;
		
		try {
			rc = dbDisc.insert(disc);
		} catch (Exception e) {
			
			e.printStackTrace();
		}
		return rc;
	}

	public int update(String type, double minAmount, double discount) {

		Discount disc = new Discount(type,minAmount,discount);
		
		return dbDisc.update(disc);
	}

	public int delete(String type) {
		return dbDisc.delete(type);
	}
	
}
